package com.ruoyi.project.sales.orders.create.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.sales.orders.create.domain.NewOrder;
import com.ruoyi.project.sales.orders.create.service.IOrderCreateService;
import com.ruoyi.project.sales.orders.search.service.IOrderSearchService;
import com.ruoyi.project.system.user.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/sales/orders/create")
public class CreateController extends BaseController {

    private String prefix = "sales/orders/create";

    @Autowired
    private IOrderCreateService orderCreateService;

    @GetMapping()
    public String search()
    {
        return prefix + "/create";
    }

    /**
     * 新增用户
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@Validated NewOrder order)
    {
        return toAjax(orderCreateService.insertOrder(order));
    }
}
